package com.tianji.aigc.controller;


import com.tianji.aigc.service.IChatSessionService;
import com.tianji.aigc.vo.MessageVO;
import com.tianji.aigc.vo.SessionVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 对话session 前端控制器
 * </p>
 *
 * @author yxy
 * @since 2025-09-02
 */
@RestController
@RequestMapping("/chat-session")
public class ChatSessionController {

    @Autowired
    private IChatSessionService chatSessionService;

    /**
     * 新建会话
     * @param sum
     * @return
     */
    @PostMapping
    public SessionVO createSession(@RequestParam(value = "n",defaultValue = "3")Integer sum){

        return chatSessionService.createSession(sum);
    }

    /**
     * 随机热门问题
     * @param num 生成热门问题的数量，默认为3
     * @return
     */
    @GetMapping("/hot")
    public List<SessionVO.Example> hotExamples(@RequestParam(value = "n", defaultValue = "3") Integer num) {
        return chatSessionService.hotExamples(num);
    }


    /**
     * 查询会话详情
     * @param sessionId
     * @return
     */
    @GetMapping("/{sessionId}")
    public List<MessageVO> messageList(@PathVariable("sessionId") String sessionId) {
        return chatSessionService.messageList(sessionId);
    }

}
